package com.sniper.controller;

import com.sniper.amqp.sender.Sender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author suzhen
 * @create 2018/3/19
 */
@RefreshScope
@RestController
public class IndexController {


    private static Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private Sender sender;

    @RequestMapping("send")
    public String send() {
        sender.send();
        return "ok";
    }

    @Value("${foo}")
    String foo;

    @Value("${demo}")
    String demo;

    @Value("${sniper.password}")
    String password;

    @RequestMapping(value = "/hi")
    public String hi() {
        logger.debug("hi: {}", foo);
        return foo;
    }

    @RequestMapping(value = "/demo")
    public String demo() {
        logger.debug("demo: {}", password);
        return password;
    }

    @RequestMapping(value = "/password")
    public String password() {
        logger.debug("password: {}", password);
        return password;
    }
}
